home *** CD-ROM | disk | FTP | other *** search
/ Australian Personal Computer 2002 November / CD 1 / APC0211D1.ISO / workshop / prog / files / ActivePerl-5.6.1.633-MSWin32.msi / _039a5d76a430b6aa6b3ad122dd015f06 < prev    next >
Encoding:
Text File  |  2002-05-30  |  2.0 KB  |  42 lines

  1.  
  2.  
  3. sub mkListbox {
  4.  
  5.     # Create a top-level window that displays a listbox with the names of the 50 states.
  6.  
  7.     $mkListbox->destroy if Exists($mkListbox);
  8.     $mkListbox = $top->Toplevel();
  9.     my $w = $mkListbox;
  10.     dpos $w;
  11.     $w->title('Listbox Demonstration (50 states)');
  12.     $w->iconname('Listbox');
  13.     $w->minsize(1, 1);
  14.  
  15.     my $w_msg = $w->Label(-font => '-Adobe-times-medium-r-normal--*-180-*-*-*-*-*-*', -justify => 'left',
  16.                -wraplength => '3.5i', -text => 'A listbox containing the 50 states is displayed below, along ' .
  17.                'with a scrollbar.  You can scan the list either using the scrollbar or by dragging in the ' .
  18.                'listbox window with button 2 pressed.  Click the "OK" button when you\'ve seen enough.');
  19.     my $w_frame = $w->Frame(-borderwidth => 10);
  20.     my $w_ok = $w->Button(-text => 'OK', -width => 8, -command => ['destroy', $w]);
  21.     $w_msg->pack(-side => 'top');
  22.     $w_frame->pack(-side => 'top', -expand => 'yes', -fill => 'y');
  23.     $w_ok->pack(-side => 'bottom');
  24.  
  25.     my $w_frame_scroll = $w_frame->Scrollbar();
  26.     my $w_frame_list = $w_frame->Listbox(-yscrollcommand => ['set', $w_frame_scroll], -setgrid => 1);
  27.     $w_frame_scroll->configure(-command => ['yview', $w_frame_list]);
  28.     $w_frame_scroll->pack(-side => 'right', -fill => 'y');
  29.     $w_frame_list->pack(-side => 'left', -expand => 'yes', -fill => 'both');
  30.  
  31.     $w_frame_list->insert(0, qw(Alabama Alaska Arizona Arkansas California Colorado Connecticut Delaware Florida Georgia Hawaii
  32.                 Idaho Illinois Indiana Iowa Kansas Kentucky Louisiana Maine Maryland Massachusetts Michigan
  33.                 Minnesota Mississippi Missouri Montana Nebraska Nevada), 'New Hampshire', 'New Jersey',
  34.                     'New Mexico', 'New York', 'North Carolina', 'North Dakota', qw( Ohio Oklahoma Oregon
  35.                      Pennsylvania), 'Rhode Island', 'South Carolina', 'South Dakota', qw(Tennessee Texas Utah 
  36.                     Vermont Virginia Washington), 'West Virginia', 'Wisconsin', 'Wyoming');
  37.  
  38. } # end mkListbox
  39.  
  40.  
  41. 1;
  42.